<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>htmlCSS实现轮播图</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            background-color: #95a5a6;
        }

        .box {
            position: relative;
            width: 400px;
            height: 300px;
            overflow: hidden;
        }

        .middle {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .order {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translate(-50%);
            display: flex;
        }

        .order label {
            margin: 6px;
            width: 50px;
            height: 10px;
            border: 2px solid pink;
            cursor: pointer;
            transition: .4s;
        }

        .order label:hover {
            background-color: pink;
        }

        input[name="bar"] {
            position: absolute;
            visibility: hidden;
        }

        .pics {
            width: 400%;
            height: 100%;
            display: flex;
        }

        .pic {
            width: 25%;
            transition: 0.6s;
        }

        .pic img {
            width: 100%;
            height: 100%;
        }

        #one:checked~.pic1 {
            margin-left: 0;
        }

        #two:checked~.pic1 {
            margin-left: -25%;
        }

        #three:checked~.pic1 {
            margin-left: -50%;
        }

        #four:checked~.pic1 {
            margin-left: -75%;
        }
    </style>
</head>

<body>
    <div class="box middle">
        <div class="pics">
            <input type="radio" name="bar" id="one" checked>
            <input type="radio" name="bar" id="two">
            <input type="radio" name="bar" id="three">
            <input type="radio" name="bar" id="four">

            <div class="pic pic1">
                <img src="../img/1.jpg" alt="">
            </div>
            <div class="pic pic2">
                <img src="../img/2.jpg" alt="">
            </div>
            <div class="pic">
                <img src="../img/3.jpg" alt="">
            </div>
            <div class="pic">
                <img src="../img/4.jpg" alt="">
            </div>

        </div>


        <div class="order">
            <label for="one"></label>
            <label for="two"></label>
            <label for="three"></label>
            <label for="four"></label>
        </div>
    </div>
</body>

</html>